import { get, post, put, del, patch } from './request'

// 用户相关接口
export const userApi = {
  // 用户登录
  login: (data) => post('/user/login', data),
  // 用户注册
  register: (data) => post('/user/register', data),
  // 获取用户信息
  getUserInfo: () => get('/user/info'),
  // 更新用户信息
  updateUserInfo: (data) => put('/user/info', data),
  // 用户登出
  logout: () => post('/user/logout')
}

// 鱼类相关接口
export const fishApi = {
  // 获取鱼类列表
  getFishList: (params) => get('/fish/list', params),
  // 获取鱼类详情
  getFishDetail: (id) => get(`/fish/detail/${id}`),
  // 添加鱼类
  addFish: (data) => post('/fish/add', data),
  // 更新鱼类信息
  updateFish: (id, data) => put(`/fish/update/${id}`, data),
  // 删除鱼类
  deleteFish: (id) => del(`/fish/delete/${id}`),
  // 鱼类搜索
  searchFish: (params) => get('/fish/search', params)
}

// 监控相关接口
export const monitorApi = {
  // 获取监控数据
  getMonitorData: (params) => get('/monitor/data', params),
  // 获取实时监控
  getRealTimeMonitor: () => get('/monitor/realtime'),
  // 获取历史数据
  getHistoryData: (params) => get('/monitor/history', params),
  // 设置监控参数
  setMonitorParams: (data) => post('/monitor/params', data)
}

// 实验相关接口
export const experimentApi = {
  // 获取实验列表
  getExperimentList: (params) => get('/experiment/list', params),
  // 获取实验详情
  getExperimentDetail: (id) => get(`/experiment/detail/${id}`),
  // 创建实验
  createExperiment: (data) => post('/experiment/create', data),
  // 更新实验
  updateExperiment: (id, data) => put(`/experiment/update/${id}`, data),
  // 删除实验
  deleteExperiment: (id) => del(`/experiment/delete/${id}`),
  // 获取实验结果
  getExperimentResult: (id) => get(`/experiment/result/${id}`)
}

// 文件上传相关接口
export const uploadApi = {
  // 上传文件
  uploadFile: (file, onProgress) => {
    const formData = new FormData()
    formData.append('file', file)
    return post('/upload/file', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      onUploadProgress: onProgress
    })
  },
  // 上传图片
  uploadImage: (file, onProgress) => {
    const formData = new FormData()
    formData.append('image', file)
    return post('/upload/image', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      onUploadProgress: onProgress
    })
  }
}

// 数据统计相关接口
export const statisticsApi = {
  // 获取统计数据
  getStatistics: (params) => get('/statistics/data', params),
  // 获取图表数据
  getChartData: (params) => get('/statistics/chart', params),
  // 获取报表数据
  getReportData: (params) => get('/statistics/report', params)
}

// 系统相关接口
export const systemApi = {
  // 获取系统配置
  getSystemConfig: () => get('/system/config'),
  // 更新系统配置
  updateSystemConfig: (data) => put('/system/config', data),
  // 获取系统日志
  getSystemLogs: (params) => get('/system/logs', params)
}

// 导出所有API
export default {
  userApi,
  fishApi,
  monitorApi,
  experimentApi,
  uploadApi,
  statisticsApi,
  systemApi
} 